#include "gtest/include/gtest/gtest.h"
#include "../../src/common/message/ngmessage.h"

class COMMON_NGMessageTest : public ::testing::Test
{
protected:
	void SetUp()
	{
		msg = new NGMessage();
	}
	void TearDown()
	{
		delete msg;
	}

	NGMessage *msg;
};

// test set/get type
TEST_F(COMMON_NGMessageTest, TypeTest)
{
	msg->setType(50);
	ASSERT_EQ(50, msg->getType());

	msg->setType(-1);
	ASSERT_EQ((BYTE) -1, msg->getType());
}

// test set/get senderId
TEST_F(COMMON_NGMessageTest, SenderIdTest)
{
	msg->setSenderId(123456);
	ASSERT_EQ(123456, msg->getSenderId());

	msg->setSenderId(1);
	ASSERT_EQ(1, msg->getSenderId());
}

// test set/get data
TEST_F(COMMON_NGMessageTest, DataTest)
{
	msg->setData("hello, world!");
	ASSERT_STREQ("hello, world!", msg->getData());
	ASSERT_EQ(strlen("hello, world!"), msg->getLength());

	msg->setData("another string..");
	ASSERT_STREQ("another string..", msg->getData());
	ASSERT_EQ(strlen("another string.."), msg->getLength());
}
